#ifndef TREEMAP_H
#define TREEMAP_H

#pragma once
#include <QVector>
#include <QRectF>
#include <QVariant>
#include <float.h>
#include "multi_tree.h"

struct SqInput
{
    double value;
    QSharedPointer<MTree> ptr;
};

struct SqOutput
{
    QSharedPointer<MTree> ptr;
    QRectF rectangle;
};

class Squarify
{

private:
    QRectF currentRc;
    QVector<SqInput> currentInput;
    QRectF unfilledRc;
    QVector<SqOutput> completedOutput;

public:
    Squarify();
    QVector<SqOutput> getSquarified(QRectF rc,const QVector<SqInput>& values,bool bClacRate = true);

private:
    void squarify(const QVector<SqInput>& inputs,const QVector<SqInput>& currValues);
    void layoutRects(const QVector<SqInput>& preValues);
    double calcWHrate(const QVector<SqInput>& currValues);

};

#endif // TREEMAP_H
